import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2023-11-29
 * Time: 14:04
 */
public class My_String {
    public static void fun() {
        String str = "hello";
        String str1 = new String("hello,world");
        char[] array = {'1','2','3','4'};
        String str2 = new String(array);
    }

    public static void main(String[] args) {
       final char[] value = {'a','b','c','d'};
        value[0] = '1';
        value = new char[10];

    }
    public static void main18(String[] args) {
        String str = "hello world java SE";
        String[] ret = str.split(" ");
        for (String s:ret) {
            System.out.println(s);
        }
    }
    public static void main17(String[] args) {
        String str = "helloworld";
        System.out.println(str.replaceAll("l", "+"));
        System.out.println(str.replaceFirst("l", "+"));
    }
    public static void main16(String[] args) {
        String s = String.format("%d-%d-%d", 2019, 9,14);
        System.out.println(s);

    }
    public static void main15(String[] args) {
        char[] chars = {'1','2','3'};
        String str = new String(chars);
        System.out.println(str);
    }
    public static void main14(String[] args) {
        String str ="abc";
        char[] chars = str.toCharArray();
        System.out.println(Arrays.toString(chars));
    }
    public static void main13(String[] args) {
        String str = new String("abc");
        String str1 = new String("ABC");
        //小写转化为大写
        System.out.println(str.toUpperCase());
        //大写转化小写
        System.out.println(str1.toLowerCase());
    }
    public static void main12(String[] args) {
        //数字转字符串
        String str = String.valueOf(123);
        System.out.println(str);
        //字符串转数字
        Integer ii = Integer.valueOf("123");
        System.out.println(ii);
    }
    public static void main11(String[] args) {
        String str = new String("hello");
        System.out.println(str.lastIndexOf("llo", 4));
        System.out.println(str.lastIndexOf("llo", 1));
        System.out.println(str.lastIndexOf("llo"));
        System.out.println(str.lastIndexOf("lle"));
        System.out.println(str.lastIndexOf('l', 4));
        System.out.println(str.lastIndexOf('l', 1));
        System.out.println(str.lastIndexOf('o'));
        System.out.println(str.lastIndexOf('a'));
    }
    public static void main10(String[] args) {
        String str = new String("hello");
        System.out.println(str.indexOf("llo", 2));
        System.out.println(str.indexOf("llo", 4));
    }
    public static void main9(String[] args) {
        String str = new String("hello");
        System.out.println(str.indexOf("llo"));
        System.out.println(str.indexOf("all"));
    }
    public static void main8(String[] args) {
        String str = new String("hello");
        System.out.println(str.indexOf('l', 3));
    }
    public static void mai7n(String[] args) {
        String str1 = new String("abcdef");
        System.out.println(str1.indexOf('a'));
        System.out.println(str1.indexOf('b'));
        System.out.println(str1.indexOf('z'));
    }
    public static void main6(String[] args) {
        String str1 = new String("abcdef");
        char ch = str1.charAt(0);//'a'
        char ch1 = str1.charAt(1);//'b'
        char ch2 = str1.charAt(-1);//抛异常
        char ch3 = str1.charAt(6);//抛异常
        System.out.println(ch);
        System.out.println(ch1);
        System.out.println(ch2);
        System.out.println(ch3);
    }
    public static void main5(String[] args) {
        String str1 = new String("abcdefg");
        String str2 = new String("abcdefg");
        String str3 = new String("ABCDEFG");
        String str4 = new String("zhangsan");
        System.out.println(str1.compareToIgnoreCase(str2));
        System.out.println(str1.compareToIgnoreCase(str3));
        System.out.println(str1.compareToIgnoreCase(str4));
    }
    public static void mai4n(String[] args) {
        String str1 = new String("abcdefg");
        String str2 = new String("abcdefg");
        String str3 = new String("ABCDEFG");
        System.out.println(str1.compareTo(str2));
        System.out.println(str1.compareTo(str3));
    }
    public static void main3(String[] args) {
        String str1 = new String("abcdefg");
        String str2 = new String("abcdefg");
        String str3 = new String("ABCDEFG");
        System.out.println(str1.equals(str2));
        System.out.println(str1.equals(str3));
    }
    public static void main2(String[] args) {
        //简单类型
        int a = 10;
        int b = 10;
        //引用类型
        String str1 = new String("abcdefg");
        String str2 = new String("abcdefg");
        //比较简单类型
        System.out.println(a == b);//true  false
        //比较引用类型
        System.out.println(str1 == str2);
    }
    public static void main1(String[] args) {
        My_String.fun();
        String str1 = new String("1234");
        String str2 = new String("12");
        String str3 = str1;
        System.out.println(str1.length());
        System.out.println(str3.isEmpty());
        System.out.println("hello".length());
    }
}
